package com.zx.system.block.dao;

import com.zx.system.block.model.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface SysUserMapper {
    int deleteByPrimaryKey(@Param("id") String id);

    int insert(SysUser row);

    int insertSelective(SysUser row);

    SysUser selectByPrimaryKey(@Param("id") String id);

    int updateByPrimaryKeySelective(SysUser row);

    int updateByPrimaryKey(SysUser row);

    SysUser findByPhoneNumber(@Param("phoneNumber") String phoneNumber, @Param("tenantId") String tenantId);

    SysUser findByEmail(@Param("email") String email, @Param("tenantId") String tenantId);

    long getUserListCount(@Param("tenantId") String tenantId,
                          @Param("deptId") String deptId,
                          @Param("name") String name,
                          @Param("email") String email,
                          @Param("phoneNumber") String phoneNumber,
                          @Param("status") Integer status,
                          @Param("createTimeStart") LocalDateTime createTimeStart,
                          @Param("createTimeEnd") LocalDateTime createTimeEnd);

    List<SysUser> getUserListByPage(@Param("tenantId") String tenantId,
                                    @Param("deptId") String deptId,
                                    @Param("name") String name,
                                    @Param("email") String email,
                                    @Param("phoneNumber") String phoneNumber,
                                    @Param("status") Integer status,
                                    @Param("createTimeStart") LocalDateTime createTimeStart,
                                    @Param("createTimeEnd") LocalDateTime createTimeEnd,
                                    @Param("pageNum") Long pageNum,
                                    @Param("pageSize") Long pageSize);

    List<SysUser> selectUserList(@Param("user") SysUser user, @Param("tenantId") String tenantId);

    /**
     * 根据用户名列表查询用户
     *
     * @param usernames 用户名列表
     * @param tenantId  租户ID
     * @return 用户列表
     */
    List<SysUser> selectByUsernames(@Param("usernames") List<String> usernames, @Param("tenantId") String tenantId);
}